//
//  Complex.m
//  oc_复数的定义
//
//  Created by blue on 16/4/14.
//  Copyright (c) 2016年 csx. All rights reserved.
//

#import "Complex.h"

@implementation Complex
//带两个参数的构造方法
-(id)initWithReal:(int)real
     andImaginary:(int)imaginary{
    self = [super init];
    if(self){
        _real = real;
        _imaginary = imaginary;
    }
    return self;
}
//带一个参数的setter方法
-(void)setReal:(int)real{
    _real = real;
}
-(void)setImaginary:(int)imaginary{
    _imaginary = imaginary;
}
//getter方法
-(int)real{
    return _real;
}
-(int)imaginary{
    return _imaginary;
}

//带一个参数，且结果直接输出的对象方法
-(void)addComplex:(Complex *)c{
    _real = _real + c.real;
    _imaginary = _imaginary+c.imaginary;
    NSLog(@"%d+%di",_real,_imaginary);
}
//带两个参数，将结果对象返回的类的方法
+(Complex *)addAComplex:(Complex *)c1
            andBComplex:(Complex *)c2{
    c1.real = c1.real +c2.real;
    c1.imaginary = c1.imaginary+c2.imaginary;
    return c1;
}
-(void)printComplex{
    NSLog(@"%d+%di",_real,_imaginary);
}
@end
